package mongo

import (
	"go.mongodb.org/mongo-driver/mongo"
	"sync"
)

type MongoConfig struct {
	Username   string   `toml:"username" yaml:"username" env:"MONGO_USERNAME"`
	Password   string   `toml:"password" yaml:"password" env:"MONGO_PASSWORD"`
	Endpoint   []string `toml:"endpoint" yaml:"endpoint" env:"MONGO_ENDPOINT"`
	Database   string   `toml:"database" yaml:"database" env:"MONGO_DATABASE"`
	AuthSource string   `toml:"auth_source" yaml:"auth_source" env:"MONGO_AUTHSOURCE"`

	db   *mongo.Database
	lock sync.Mutex
}

func NewMongoConfig() *MongoConfig {
	return &MongoConfig{
		Username:   "admin",
		Password:   "admin",
		Endpoint:   []string{"127.0.0.1:27017"},
		Database:   "test",
		AuthSource: "admin",
	}
}
